using UnityEngine;

public class biglevel : MonoBehaviour
{
	public int levelindex;

	public GameObject uiobj;

	public UIEventListener boxbtn1;

	public UIEventListener boxbtn2;

	public UISlider starslider;

	public TweenScale box1anima;

	public TweenScale box2anima;

	public UISprite box1gou;

	public UISprite box2gou;

	public UISprite pointflag1;

	public UISprite pointflag2;

	private int allstar;

	private void Start()
	{
		boxbtn1.onClick = onclickboxone;
		boxbtn2.onClick = onclickboxtwo;
	}

	public void onclickboxone(GameObject btn)
	{
		if (allstar < 9)
		{
			MonoInstance<AudioController>.instance.play(AudioType.UI_pophit, 0f);
			MenuUIController.instance.enable_hitinfoui(hitinfoid.box_star);
		}
		else if (MenuPlayerprefs.instance.levelboxinfo[levelindex * 2] == 0)
		{
			MenuPlayerprefs.instance.setlevelbox(levelindex * 2);
			MenuUIController.instance.enable_getreward(levelindex, isone: true);
			show_box();
		}
		else
		{
			MonoInstance<AudioController>.instance.play(AudioType.UI_pophit, 0f);
			MenuUIController.instance.enable_hitinfoui(hitinfoid.box_claim);
		}
	}

	public void onclickboxtwo(GameObject btn)
	{
		if (allstar < 18)
		{
			MonoInstance<AudioController>.instance.play(AudioType.UI_pophit, 0f);
			MenuUIController.instance.enable_hitinfoui(hitinfoid.box_star);
		}
		else if (MenuPlayerprefs.instance.levelboxinfo[levelindex * 2 + 1] == 0)
		{
			MenuPlayerprefs.instance.setlevelbox(levelindex * 2 + 1);
			MenuUIController.instance.enable_getreward(levelindex, isone: false);
			show_box();
		}
		else
		{
			MonoInstance<AudioController>.instance.play(AudioType.UI_pophit, 0f);
			MenuUIController.instance.enable_hitinfoui(hitinfoid.box_claim);
		}
	}

	public void init_ui_info()
	{
		allstar = MenuPlayerprefs.instance.getlevel_star(levelindex);
		starslider.value = (float)allstar / 18f - 0.15f;
		show_box();
	}

	public void show_box()
	{
		if (MenuPlayerprefs.instance.levelboxinfo[levelindex * 2] == 0 && allstar >= 9)
		{
			box1anima.PlayForward();
			pointflag1.enabled = true;
		}
		else
		{
			box1anima.enabled = false;
			pointflag1.enabled = false;
		}
		if (MenuPlayerprefs.instance.levelboxinfo[levelindex * 2 + 1] == 0 && allstar == 18)
		{
			box2anima.PlayForward();
			pointflag2.enabled = true;
		}
		else
		{
			box2anima.enabled = false;
			pointflag2.enabled = false;
		}
		if (MenuPlayerprefs.instance.levelboxinfo[levelindex * 2] == 1 && allstar >= 9)
		{
			box1gou.enabled = true;
		}
		else
		{
			box1gou.enabled = false;
		}
		if (MenuPlayerprefs.instance.levelboxinfo[levelindex * 2 + 1] == 1 && allstar == 18)
		{
			box2gou.enabled = true;
		}
		else
		{
			box2gou.enabled = false;
		}
	}

	public void enable()
	{
		NGUITools.SetActive(uiobj, state: true);
		init_ui_info();
	}

	public void disable()
	{
		NGUITools.SetActive(uiobj, state: false);
	}
}
